package com.framework.controller.newcontroller;

import com.framework.exception.util.RespResult;
import com.framework.service.BenefitInfoService;
import com.framework.service.TransactionInfoService;
import com.framework.view.SeparatMonthView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 功能描述:
 *
 * @author ck 交易相关
 * @date 2018/9/7 16:42
 */
@RestController
@RequestMapping(value = "new/transaction")
@Api(tags = {"交易模块"})
public class NewTransactionController {

	@Autowired
	private TransactionInfoService transactionInfoService;

	/**
	 * 获取根据sn获取交易记录
	 * @param sn
	 * @param startDate
	 * @param endDate
	 * @return
	 */
	@GetMapping("user/queryTranListBySn")
	@ApiOperation("商户详情 获取根据sn获取交易记录")
	@ApiImplicitParams({
			@ApiImplicitParam(name="sn",value="机具编码",dataType="string", paramType = "query" ),
			@ApiImplicitParam(name="startDate",value="交易开始时间",dataType="string", paramType = "query" ),
			@ApiImplicitParam(name="endDate",value="交易结束时间",dataType="string", paramType = "query" )
	})
	public RespResult queryTranListBySn(String sn,String startDate,String endDate) {
		Map<String,Object> map= transactionInfoService.queryTranListBySn(sn, startDate, endDate);
		return RespResult.ok(map);
	}

	/**
	 * 数据管理明细
	 * @param token
	 * @param agentId
	 * @param types
	 * @return
	 */
	@GetMapping("user/queryTransactionTimeList")
	@ApiOperation("数据管理明细")
	@ApiImplicitParams({
			@ApiImplicitParam(name="agentId",value="代理商id",dataType="long", paramType = "query"),
			@ApiImplicitParam(name="types",value="月交易：month  天交易：day",dataType="string", paramType = "query",required = true),
			@ApiImplicitParam(name="pageNo",value="页数,1",dataType="string", paramType = "query",required = true),
	})
	public RespResult queryTransactionTimeList(String token, Long agentId, String types,Integer pageNo) {
		Map<String,Object> map = transactionInfoService.queryTransactionTimeMap( token, agentId, types,pageNo);
		return RespResult.ok().put("map",map);
	}

	/**
	 *  代理商拓展信息
	 * @param token
	 * @return
	 */
	@GetMapping("user/getExpand")
	@ApiOperation("代理商拓展信息")
	@ApiImplicitParams({
			@ApiImplicitParam(name="token",value="登录产生的token",dataType="String", paramType = "query"),
			@ApiImplicitParam(name="type",value="收益类型 昨日：1 本月：2",dataType="int", paramType = "query",required = true),
	})
	public RespResult getExpand(String token,Integer type) {
		Map<String,Object> map = transactionInfoService.getExpandInfo(token,type);
		return RespResult.ok(map);
	}

}
